home *** CD-ROM | disk | FTP | other *** search
/ The Very Best of Atari Inside / The Very Best of Atari Inside 1.iso / mint / mntinc25 / falcon.h < prev    next >
C/C++ Source or Header  |  1992-12-12  |  12KB  |  352 lines

  1. /*
  2.  * GNU-C Bindings for Falcon XBIOS functions
  3.  * -- hyc 11-9-92 (uunet!hanauma.Jpl.Nasa.Gov!hyc)
  4.  */
  5.  
  6. #ifndef _OSBIND_H
  7. #include <osbind.h>
  8. #endif
  9.  
  10. #ifndef trap_14_wwwwww
  11. #define trap_14_wwwwww(n,a,b,c,d,e)                    \
  12. ({                                    \
  13.     register long retvalue __asm__("d0");                \
  14.     short _a = (short)(a);                        \
  15.     short _b = (short)(b);                        \
  16.     short _c = (short)(c);                        \
  17.     short _d = (short)(d);                        \
  18.     short _e = (short)(e);                        \
  19.                                     \
  20.     __asm__ volatile                        \
  21.     ("\
  22.         movw    %4,sp@-; \
  23.         movw    %3,sp@-; \
  24.         movw    %2,sp@-; \
  25.         movw    %1,sp@-; \
  26.         movw    %0,sp@- "                    \
  27.     :: "r"(_a), "r"(_b), "r"(_c), "r"(_d), "r"(_e));        \
  28.                                     \
  29.     __asm__ volatile                        \
  30.     ("\
  31.         movw    %1,sp@-; \
  32.         trap    #14; \
  33.         lea    sp@(12),sp"                    \
  34.     : "=r"(retvalue)                        \
  35.     : "g"(n)                            \
  36.     : "d0", "d1", "d2", "a0", "a1", "a2");                \
  37.     retvalue;                            \
  38. })
  39. #endif
  40.  
  41. /*
  42.  * Video
  43.  */
  44.  
  45. /* Video mode codes */
  46.  
  47. #define    VERTFLAG    0x100    /* double-line on VGA, interlace on ST/TV */
  48. #define    STMODES        0x080    /* ST compatible */
  49. #define    OVERSCAN    0x040    /* Multiply X&Y rez by 1.2, ignored on VGA */
  50. #define    PAL        0x020    /* PAL if set, else NTSC */
  51. #define    VGA        0x010    /* VGA if set, else TV mode */
  52. #define    COL80        0x008    /* 80 column if set, else 40 column */
  53. #define    NUMCOLS        7    /* Mask for number of bits per pixel */
  54. #define    BPS16        4
  55. #define    BPS8        3
  56. #define    BPS4        2
  57. #define    BPS2        1
  58. #define    BPS1        0
  59.  
  60. /* Montype return values */
  61. enum montypes = {STmono=0, STcolor, VGAcolor, TVcolor};
  62.  
  63. /* VsetSync flags - 0=internal, 1=external */
  64.  
  65. #define    VID_CLOCK    1
  66. #define    VID_VSYNC    2
  67. #define    VID_HSYNC    4
  68.  
  69. #undef Setscreen
  70. #define Setscreen(lscrn,pscrn,rez,mode)                    \
  71.     (short)trap_14_wllww((short)5,(long)(lscrn),(long)(pscrn),    \
  72.         (short)(rez),(short)(mode))
  73. #define Vsetmode(mode)                            \
  74.     (short)trap_14_ww((short)88,(short)(mode))
  75. #define Montype()                            \
  76.     (short)trap_14_w((short)89)
  77. #define    VgetSize(mode)                            \
  78.     (long)trap_14_ww((short)91,(short)(mode))
  79. #define    VsetSync(ext)                            \
  80.     (void)trap_14_ww((short)90,(short)(ext))
  81. #define VsetRGB(index,count,array)                    \
  82.     (void)trap_14_wwwl((short)93,(short)(index),(short)(count),    \
  83.         (long *)(array))
  84. #define VgetRGB(index,count,array)                    \
  85.     (void)trap_14_wwwl((short)94,(short)(index),(short)(count),    \
  86.         (long *)(array))
  87. #define VsetMask(andmask,ormask)                    \
  88.     (void)trap_14_www((short)150,(short)(andmask),(short)(ormask))
  89.  
  90. /*
  91.  * Sound
  92.  */
  93.  
  94. /* _SND cookie values */
  95.  
  96. #define SND_PSG        0x01    /* Yamaha PSG */
  97. #define    SND_8BIT    0x02    /* 8 bit DMA stereo */
  98. #define    SND_16BIT    0x04    /* 16 bit CODEC */
  99. #define    SND_DSP        0x08    /* DSP */
  100. #define    SND_MATRIX    0x10    /* Connection Matrix */
  101.  
  102. /* XXX Docs say Falcon shows 0x3f. What does bit 0x20 mean ??? */
  103.  
  104. /*
  105.  * Sound data memory layout - samples are all signed values
  106.  *
  107.  *                 (each char = 1 byte, 2 chars = 1 word)
  108.  * 1 16 bit stereo track:    LLRRLLRRLLRRLLRR
  109.  * 1 8 bit stereo track:    LRLRLRLR  
  110.  * 2 16 bit stereo tracks:    L0R0L1R1L0R0L1R1
  111.  *  etc...
  112.  */
  113.  
  114. /* Setbuffer regions */
  115.  
  116. #define    SR_PLAY        0    /* Set playback registers */
  117. #define    SR_RECORD    1    /* Set record registers */
  118.  
  119. /* Soundcmd Modes */
  120.  
  121. #define LTATTEN        0    /* Left-channel output attenuation */
  122. #define    RTATTEN        1    /* Right channel atten */
  123. #define    LTGAIN        2    /* Left input gain */
  124. #define    RTGAIN        3    /* Right channel gain */
  125.     /* gain and attenuation in 1.5db units, 0x00V0, V:0-15 */
  126. #define    ADDERIN        4    /* Select inputs to adder 0=off, 1=on */
  127. #define    ADCIN        1    /* Input from ADC */
  128. #define    MATIN        2    /* Input from connection matrix */
  129. #define    ADCINPUT    5    /* Select input to ADC, 0=mic, 1=PSG */
  130. #define    ADCRT        1    /* Right channel input */
  131. #define    ADCLT        2    /* Left input */
  132. #define    SETPRESCALE    6    /* Set TT compatibility prescaler */
  133. #define    PREMUTE        0    /* was /1280, now is invalid, mutes */
  134. #define    PRE1280        PREMUTE
  135. #define    PRE640        1    /* divide by 640 */
  136. #define    PRE320        2    /* / 320 */
  137. #define    PRE160        3    /* / 160 */
  138.  
  139. /* Record/Playback modes */
  140.  
  141. #define    STEREO8        0    /* 8 bit stereo */
  142. #define    STEREO16    1    /* 16 bit stereo */
  143. #define    MONO8        2    /* 8 bit mono */
  144.  
  145. /* Record/Playback tracks range from 0 to 3 */
  146.  
  147. /* XXX Doc for Settracks could be clearer. Can we individually set, e.g.,
  148.    tracks 0 & 2 for playback, or must track selections be contiguous? */
  149.  
  150. /* Sound buffer interrupts */
  151.     /* sources */
  152. #define    SI_TIMERA    0    /* Timer A interrupt */
  153. #define    SI_MFPI7    1    /* MFP interrupt 7 */
  154.     /* causes */
  155. #define    SI_NONE        0    /* No interrupts */
  156. #define    SI_PLAY        1    /* Intr at end of play buffer */
  157. #define    SI_RECORD    2    /* Intr at end of record buffer */
  158. #define    SI_BOTH        3    /* Interrupt for either play or record */
  159.  
  160. /* Buffoper flags */
  161.  
  162. #define    SB_PLA_ENA    1    /* Play enable */
  163. #define    SB_PLA_RPT    2    /* Play repeat (continuous loop mode) */
  164. #define    SB_REC_ENA    4    /* Record enable */
  165. #define SB_REC_RPT    8    /* Record repeat */
  166.  
  167. /* Dsptristate - 0=tristate, 1=enable */
  168.  
  169. /* Gpio modes */
  170.  
  171. #define    GPIO_SET    0    /* Set I/O direction, 0=in, 1=out */
  172. #define    GPIO_READ    1    /* Read bits - only 3 bits on gpio */
  173. #define    GPIO_WRITE    2    /* Write gpio data bits */
  174.  
  175. /* Devconnect (connection matrix) source devices */
  176.  
  177. #define    DMAPLAY        0    /* DMA playback */
  178. #define    DSPXMIT        1    /* DSP transmit */
  179. #define    EXTINP        2    /* External input */
  180. #define    ADC        3    /* Microphone/PSG, see Soundcmd(ADCINPUT) */
  181.  
  182. /* Devconnect destination devices, bitmapped */
  183.  
  184. #define    DMAREC        1    /* DMA record */
  185. #define    DSPRECV        2    /* DSP receive */
  186. #define    EXTOUT        4    /* External output */
  187. #define    DAC        8    /* Headphone, internal speaker, monitor */
  188.  
  189. /* Devconnect clock sources */
  190.  
  191. #define    CLK25M        0    /* Internal 25.175 MHz clock */
  192. #define    CLKEXT        1    /* External clock */
  193. #define    CLK32M        2    /* Internal 32 MHz. Invalid for CODEC */
  194.  
  195. /* Devconnect clock prescaler values */
  196.  
  197. /* XXX Doc lists incorrect hz numbers for many of these... */
  198.  
  199. #define CLKOLD        0    /* TT compatible, see Soundcmd(SETPRESCALE) */
  200. #define    CLK50K        1    /* 49170 hz */
  201. #define    CLK33K        2    /* 32780 hz */
  202. #define    CLK25K        3    /* 24585 hz */
  203. #define    CLK20K        4    /* 19668 hz */
  204. #define    CLK16K        5    /* 16390 hz */
  205.         /*    6    (14049 hz) invalid for CODEC */
  206. #define    CLK12K        7    /* 12292 hz */
  207.         /*    8    (10927 hz) invalid for CODEC */
  208. #define    CLK10K        9    /* 9834 hz */
  209.         /*    10    (8940 hz) invalid for CODEC */
  210. #define    CLK8K        11    /* 8195 hz */
  211.         /*    12    (7565 hz) invalid */
  212.         /*    13    (7024 hz) invalid */
  213.         /*    14    (6556 hz) invalid */
  214.         /*    15    (6146 hz) invalid */
  215.  
  216. /* Sndstatus command */
  217.  
  218. #define    SND_CHECK    0    /* Check current status */
  219. #define    SND_RESET    1    /* Reset sound system */
  220.     /*
  221.      * Reset effects: DSP tristated, gain=atten=0, matrix reset,
  222.      * ADDERIN=0, Mode=STEREO8, Play=Record=Monitor tracks=0,
  223.      * interrupts disabled, buffer operation disabled.
  224.      */
  225.  
  226. /* Sndstatus status return */
  227.  
  228. #define    SS_OK        0    /* No errors */
  229. #define    SS_CTRL        1    /* Invalid control field (Data assumed OK) */
  230. #define    SS_SYNC        2    /* Invalid sync format (mutes) */
  231. #define    SS_SCLK        3    /* Serial clock out of valid range (mutes) */
  232.  
  233. #define    SS_RTCLIP    0x10    /* Right channel is clipping */
  234. #define    SS_LTCLIP    0x20    /* Left channel is clipping */
  235.  
  236. /* Structure used by Buffptr */
  237.  
  238. typedef struct SndBufPtr {
  239.     char *play;
  240.     char *record;
  241.     long reserve1;
  242.     long reserve2;
  243. } SndBufPtr;
  244.  
  245. #define Locksnd()                            \
  246.     (long)trap_14_w((short)128)
  247. #define Unlocksnd()                            \
  248.     (long)trap_14_w((short)129)
  249. #define Setbuffer(region,beg,end)                    \
  250.     (long)trap_14_wwll((short)131,(short)(region),(long)(beg),(long)(end))
  251. #define Soundcmd(mode,data)                        \
  252.     (long)trap_14_www((short)130,(short)(mode),(short)(data))
  253. #define Setmode(stereo_mode)                        \
  254.     (long)trap_14_ww((short)132,(short)(stereo_mode))
  255. #define Settracks(play,rec)                        \
  256.     (long)trap_14_www((short)133,(short)(play),(short)(rec))
  257. #define Setmontracks(montrack)                        \
  258.     (long)trap_14_ww((short)134,(short)(montrack))
  259. #define Setinterrupt(src_inter,cause)                    \
  260.     (long)trap_14_www((short)135,(short)(src_inter),        \
  261.         (short)(cause))
  262. #define Buffoper(mode)                            \
  263.     (long)trap_14_ww((short)136,(short)(mode))
  264. #define Dsptristate(dspxmit,dsprec)                    \
  265.     (long)trap_14_www((short)137,(short)(dspxmit),            \
  266.         (short)(dsprec))
  267. #define Gpio(mode,data)                            \
  268.     (long)trap_14_www((short)138,(short)(mode),(short)(data))
  269. #define Devconnect(src,dst,sclk,pre,proto)                \
  270.     (long)trap_14_wwwwww((short)139,(short)(src),(short)(dst),    \
  271.         (short)(sclk),(short)(pre),(short)(proto))
  272. #define Sndstatus(reset)                        \
  273.     (long)trap_14_ww((short)140,(short)(reset))
  274. #define Buffptr(ptr)                            \
  275.     (long)trap_14_wl((short)141,(long)(ptr))
  276.  
  277. /*
  278.  * DSP functions
  279.  *
  280.  * Don't even *think* of trying to use these without the manual!
  281.  */
  282.         
  283. #define    Dsp_DoBlock(data_in,size_in,data_out,size_out)            \
  284.     (void)trap_14_wllll((short)96,(long)(data_in),(long)(size_in),    \
  285.         (long)(data_out),(long)(size_out))
  286. #define    Dsp_BlkHandShake(data_in,size_in,data_out,size_out)        \
  287.     (void)trap_14_wllll((short)97,(long)(data_in),(long)(size_in),    \
  288.         (long)(data_out),(long)(size_out))
  289. #define    Dsp_BlkUnpacked(data_in,size_in,data_out,size_out)        \
  290.     (void)trap_14_wllll((short)98,(long)(data_in),(long)(size_in),    \
  291.         (long)(data_out),(long)(size_out))
  292. #define    Dsp_BlkWords(data_in,size_in,data_out,size_out)            \
  293.     (void)trap_14_wllll((short)123,(long)(data_in),(long)(size_in),    \
  294.         (long)(data_out),(long)(size_out))
  295. #define    Dsp_BlkBytes(data_in,size_in,data_out,size_out)            \
  296.     (void)trap_14_wllll((short)124,(long)(data_in),(long)(size_in),    \
  297.         (long)(data_out),(long)(size_out))
  298. #define    Dsp_MultBlocks(numsend,numrecv,sendblks,recvblks)        \
  299.     (void)trap_14_wllll((short)127,(long)(numsend),(long)(numrecv),    \
  300.         (long)(sendblks),(long)(recvblks))
  301. #define    Dsp_InStream(data_in,blksiz,numblks,blksdone)            \
  302.     (void)trap_14_wllll((short)99,(long)(data_in),(long)(blksiz),    \
  303.         (long)(numblks),(long)(blksdone))
  304. #define    Dsp_OutStream(data_out,blksiz,numblks,blksdone)            \
  305.     (void)trap_14_wllll((short)100,(long)(data_out),(long)(blksiz),    \
  306.         (long)(numblks),(long)(blksdone))
  307. #define    Dsp_IOStream(data_in,data_out,blkisiz,blkosiz,numblks,blksdone)    \
  308.     (void)trap_14_wllllll((short)101,(long)(data_in),(long)(data_out),\
  309.         (long)(blkisiz),(long)(blkosiz),(long)(numblks),    \
  310.         (long)(blksdone))
  311. #define    Dsp_SetVectors(rcvr,xmtr)                    \
  312.     (void)trap_14_wll((short)126,(long)(rcvr),(long)(xmtr))
  313. #define    Dsp_RemoveInterrupts(mask)                    \
  314.     (void)trap_14_ww((short)102,(short)(mask))
  315. #define    Dsp_GetWordSize()    (long)trap_14_w((short)103)
  316. #define    Dsp_Lock()        (long)trap_14_w((short)104)
  317. #define    Dsp_Unlock()        (void)trap_14_w((short)105)
  318. #define    Dsp_Available(xmem,ymem)                    \
  319.     (void)trap_14_wll((short)106,(long)(xmem),(long)(ymem))
  320. #define    Dsp_Reserve(xmem,ymem)                        \
  321.     (void)trap_14_wll((short)107,(long)(xmem),(long)(ymem))
  322. #define    Dsp_LoadProg(file,ability,buffer)                \
  323.     (long)trap_14_wlwl((short)108,(long)(file),(short)(ability),    \
  324.         (long)(buffer))
  325. #define    Dsp_ExecProg(codeptr,codesiz,ability)                \
  326.     (void)trap_14_wllw((short)109,(long)(codeptr),(long)(codesiz),    \
  327.         (short)(ability))
  328. #define    Dsp_ExecBoot(codeptr,codesiz,ability)                \
  329.     (void)trap_14_wllw((short)110,(long)(codeptr),(long)(codesiz),    \
  330.         (short)(ability))
  331. #define    Dsp_LodToBinary(file,codeptr)                    \
  332.     (long)trap_14_wll((short)111,(long)(file),(long)(codeptr))
  333. #define    Dsp_TriggerHC(vector)                        \
  334.     (void)trap_14_ww((short)112,(short)(vector))
  335. #define    Dsp_RequestUniqueAbility()    (long)trap_14_w((short)113)
  336. #define    Dsp_GetProgAbility()        (long)trap_14_w((short)114)
  337. #define    Dsp_FlushSubroutines()        (void)trap_14_w((short)115)
  338. #define    Dsp_LoadSubroutine(ptr,siz,ability)                \
  339.     (long)trap_14_wllw((short)116,(long)(ptr),(long)(siz),        \
  340.         (short)(ability))
  341. #define    Dsp_InqSubrAbility(ability)                    \
  342.     (long)trap_14_ww((short)117,(short)(ability))
  343. #define    Dsp_RunSubroutine(handle)                    \
  344.     (long)trap_14_ww((short)118,(short)(handle))
  345. #define    Dsp_Hf0(flag)                            \
  346.     (long)trap_14_ww((short)119,(short)(flag))
  347. #define    Dsp_Hf1(flag)                            \
  348.     (long)trap_14_ww((short)120,(short)(flag))
  349. #define    Dsp_Hf2()        (long)trap_14_w((short)121)
  350. #define    Dsp_Hf3()        (long)trap_14_w((short)122)
  351. #define    Dsp_HStat()        (char)trap_14_w((short)125)
  352.